using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using NetROS.Tiers.Entities;
using System.Windows.Forms;

namespace NetRosApp.Klijenti.Reports
{
    public partial class ReversIspis : DevExpress.XtraReports.UI.XtraReport, IParametriIzvjestaja
    {
        public ReversIspis()
        {
            InitializeComponent();
        }

        public ReversIspis(Dokument dokument)
        {
            InitializeComponent();
            bindingSource1.DataSource = dokument;
            //   if (dokument.IDDokumentTip == 30) xrLabel55.Visible = false;
            xrDatumMjesto.Text = string.Format("[IDOrganizacijaOdSource.IDMjestoSource.Naziv], {0}", DateTime.Now.ToShortDateString());
            //System.Drawing.Imaging.Metafile tmp = new System.Drawing.Imaging.Metafile(@"H:\NetROS\NetRosApp\Slike\Reporti\zaglavlje.wmf");
            


        }

        #region IParametriIzvjestaja Members

        public void SetParametri()
        {
            xrLParametar1.Text = (bindingSource1.DataSource as Dokument).IDDokumentTipSource.PrilagodenDokumentTip.Parametar1;
            XrLabelParametar2.Text = (bindingSource1.DataSource as Dokument).IDDokumentTipSource.PrilagodenDokumentTip.Parametar2;
            //if (xrLParametar1.Text != String.Empty)
            //{
            //    GroupFooter2.Visible = false;
            //}
            //String Otpremnice = String.Empty;
            //foreach (Veza tmp in (bindingSource1.DataSource as Dokument).VezaCollectionGetByIDParent)
            //{
            //    if (tmp.IDChildSource.IDDokumentTip == (int)DokumentTipList.Otpremnica)
            //    {
            //        xrLabel55.Visible = false;
            //        xrLabel24.Visible = false;
            //        xrLabel27.Visible = false;
            //        xrlIzdatnice.Visible = true;
            //        xrLOtprem.Visible = true;
            //        Otpremnice += tmp.IDChildSource.Oznaka + " ";
            //    }
            //}
            //xrlIzdatnice.Text = Otpremnice;
              Dokument dokument = (bindingSource1.DataSource as Dokument);
            if (dokument != null &&  dokument.IDOrganizacijaOdSource != null && !String.IsNullOrEmpty(dokument.IDOrganizacijaOdSource.Adresa)
              && !String.IsNullOrEmpty(dokument.IDOrganizacijaOdSource.Telefon)
              && dokument.IDOrganizacijaOdSource.IDMjestoSource != null)
            {
                xrPanel1.Visible = true;
            }
            else
            {
                xrPanel1.Visible = false;
            }
        }

        #endregion

        private void xrLabel16_SummaryCalculated(object sender, TextFormatEventArgs e)
        {
            //if (e.Value != null)
            //{
            //    xrLabel16.Summary.FormatString = "{0:n2}";
            //}

        }

        private void xrLabel33_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            //try
            //{

            //    xrLabel33.Text = (bindingSource1.DataSource as Dokument).Oznaka.ToString() + "-" + (bindingSource1.DataSource as Dokument).IDKlijentSource.MB.ToString();
            //}
            //catch
            //{
            //}
        }

        private void xrLabel58_PrintOnPage(object sender, PrintOnPageEventArgs e)
        {
            if (e.PageIndex != 0)
            {
                (sender as XRLabel).Visible = true;
            }
            else
            {
                (sender as XRLabel).Visible = false;
            }
        }



    }
}
